Skip to main content

04 Work With Microbit

2023-06-20_16-19-01.png

初始化配置

  1. Go to the makecode homepage and click on New Project https://makecode.microbit.org/

    image.png

  2. Extensions -> Search for 'sugar' -> add

    image.png

案例程序

IoT MQTT

Sugar camera can be used as a wifi module.

connect

image.png :::

image.png

Coding

https://makecode.microbit.org/_cU6MpmPyLKPY

microbit-screenshot1

Code Explanation

After downloading the programme, wait for a moment, the microbit will light up to indicate that the initialisation of the module is complete.

After that, it will continuously get the latest news of the topic from the mqtt server, you can press buttonA or ButtonB to send a test message to the topic, after a while the microbit will display "√" and then output the latest news received by the topic.

You can use KittenBot's IOT platform or other MQTT IOT platforms.

https://iot.kittenbot.cn/

image-20230914233618205

Or send a message on a topic via the web

image.png

speech recognition

intro

With the microphone in the camera and the wifi function, we can upload the audio data to the cloud(BaiduAI in China), process it for speech recognition, and then have the microbit display different expressions based on the results.

Connect

image.png

Coding

https://makecode.microbit.org/_c8HRtPUMpMJX

microbit-screenshot2

QR code

Connect

image.png

Coding

https://makecode.microbit.org/_HARTjeXa084j

microbit-screenshot3

程序讲解

  1. After the program is uploaded and successfully initialised, the microbit will light up with love. Pressing button A will identify the QR code. If the code is recognised, it will return None. Because there is no screen assistance, it is easy to cause the camera screen is not complete QR code. Here we recommend that you build a mechanical structure, so that almost never scan code failure.
  2. The height of the camera from the QR code is about 10cm, and the size of the QR code is 6.5x6.5cm https://cli.im/text It is recommended that you use a straw QR code website to generate the content in English or string!

take a picture

Before unplugging the TF card, you need to switch off the power first.

image.png

:::

Connect

image.png

Coding

https://makecode.microbit.org/_P0YTveKx1gYg

microbit-screenshot4

Code Explanation

After successful download, press the a button to take a photo and save it to the TF card. You can take it photo out by card reader.